package loan.calc.constant.dict;

import loan.calc.constant.dict.base.DictEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;
import loan.calc.constant.dict.base.BaseDictEnum;

import java.time.temporal.ChronoUnit;

import static java.time.temporal.ChronoUnit.*;

/**
 * 还款频率枚举
 *
 * @author Liusuo Dong
 * @date 2020/9/23
 */
@Getter
@AllArgsConstructor
@DictEnum(value = "RepayFrequencyType", description = "还款频率")
public enum RepayFrequencyTypeEnum implements BaseDictEnum {

    DOUBLE_WEEK("按双周", DAYS, 14),
    MONTH( "按月",MONTHS, 1),
    QUARTER("按季", MONTHS, 3),
    FIXED_QUARTER("固定季",MONTHS, 3),
    ONCE("一次",FOREVER, 0),
    ASSIGN("指定周期", null, null),
    ;

    private final String value;

    private final String description;

    /**
     * 还款频率单位
     */
    private final ChronoUnit frequencyUnit;

    /**
     * 还款频率数量
     */
    private final Integer repayFrequency;

    RepayFrequencyTypeEnum(String description,
                           ChronoUnit frequencyUnit,
                           Integer repayFrequency ) {
        this.description = description;
        this.value = name();
        this.frequencyUnit = frequencyUnit;
        this.repayFrequency = repayFrequency;
    }

}
